package edu.isquen.core.document.service;

import edu.isquen.core.base.action.ParamsTable;
import edu.isquen.core.base.dao.IBaseDAO;
import edu.isquen.core.base.model.ValueObject;
import edu.isquen.core.base.service.BaseServiceImpl;
import edu.isquen.core.document.model.Document;
import edu.isquen.core.form.model.Form;
import edu.isquen.core.user.model.User;
import edu.isquen.util.factory.DaoFactory;

public class DocumentServiceImpl extends BaseServiceImpl implements
		DocumentService {

	private static final long serialVersionUID = -8038311376408777857L;

	@Override
	public IBaseDAO<?> getDao() throws Exception {
		return DaoFactory.getDao(Document.class.getName());
	}

	public Document doNew(Form form, User user, ParamsTable params)
			throws Exception {
		Document newDoc = form.createDocument(params, user);
		return newDoc;
	}

	public void doCreateOrUpdate(ValueObject vo, User user) throws Exception {
		try {
			Document doc=(Document) vo;
			doCreate(doc);
		} catch (Exception ex) {
			ex.printStackTrace();
			throw ex;
		}
	}
}
